package com.cy.springcloudalibaba.controllers;

import com.cy.springcloudalibaba.services.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @Description: 账户
 * @ClassName: AccountController
 * @Author: chenyu
 * @Date: 2025/2/6 14:39
 */
@Slf4j
@RestController
public class AccountController {
    @Autowired
    private AccountService accountService;

    @PostMapping("/account/reduceBalance")
    public void reduceBalance(@RequestParam("userId") Integer userId, @RequestParam("price") BigDecimal price) throws Exception {
        log.info("[reduceBalance] 收到减少余额请求，用户：{}，金额：{}", userId, price);
        accountService.reduceBalance(userId, price);
    }
}
